<?php

namespace App\Http\Middleware;

use App\Constants\UserStatusConstant;
use App\Helpers\Logger\SLogger;
use App\Helpers\RestUtils;
use App\Models\Factory\IdentityFactory;
use App\Models\Factory\UserFactory;
use App\Models\Factory\UserImageFactory;
use App\Models\Factory\UserStatusFactory;
use Closure;
use App\Helpers\RestResponseFactory;


/**
 * 验证图片状态中间件
 *
 * Class TokenMiddleware
 * @package App\Http\Middleware
 */
class ImageStatusMiddleware
{
    public function handle($request, Closure $next)
    {
        $result =  $next($request);

        $user = $request -> get('user');
        //验证是否成功完成
        $isComplete = $request -> get('isComplete');

        if($isComplete) {

            //用户图片信息状态
            $step3 = UserImageFactory::getUserImage($user->id) ? '1' : '0';

            //修改用户状态表里图片状态
            $resultImage = UserStatusFactory::updateUserStatus($user->id, $step3, UserStatusConstant::IMAGE);
        }
        return $result;

    }

}
